home *** CD-ROM | disk | FTP | other *** search
/ Champak 52 / Volume 52 - JOGO DISK .iso / Games / skipandgouls.swf / scripts / __Packages / maze / MazeModel.as < prev    next >
Text File  |  2007-10-01  |  4KB  |  113 lines

  1. class maze.MazeModel
  2. {
  3.    function MazeModel(l_nWidth, l_nHeight)
  4.    {
  5.       this.nWidth = l_nWidth;
  6.       this.nHeight = l_nHeight;
  7.       this.aElementList = [];
  8.       this.generateEmptyGrid();
  9.    }
  10.    function addElementFloor(l_nX, l_nY, l_nWidth, l_nHeight)
  11.    {
  12.       this.aElementList.push({element:maze.MazeData.ELEMENT_FLOOR,w:l_nWidth,h:l_nHeight,x:l_nX,y:l_nY});
  13.    }
  14.    function addElementWall(l_nX, l_nY)
  15.    {
  16.       this.aElementList.push({element:maze.MazeData.ELEMENT_WALL,x:l_nX,y:l_nY});
  17.    }
  18.    function addElementWalkway(l_nX, l_nY, l_nWidth)
  19.    {
  20.       this.aElementList.push({element:maze.MazeData.ELEMENT_WALKWAY,x:l_nX,y:l_nY,width:l_nWidth});
  21.    }
  22.    function addElementPipe(l_nX, l_nY, l_nHeight, l_bLastPipe)
  23.    {
  24.       this.aElementList.push({element:maze.MazeData.ELEMENT_PIPE,x:l_nX,y:l_nY,height:l_nHeight,lastPipe:l_bLastPipe});
  25.    }
  26.    function addElementSpiderWeb(l_nX, l_nY, l_bFlipped)
  27.    {
  28.       this.aElementList.push({element:maze.MazeData.ELEMENT_SPIDERWEB,x:l_nX,y:l_nY,flipped:l_bFlipped});
  29.    }
  30.    function addElementWindow(l_nX, l_nY, l_nWidth, l_nNumber)
  31.    {
  32.       this.aElementList.push({element:maze.MazeData.ELEMENT_WINDOW,x:l_nX,y:l_nY,width:l_nWidth,number:l_nNumber});
  33.    }
  34.    function addElementCandle(l_nX, l_nY)
  35.    {
  36.       this.aElementList.push({element:maze.MazeData.ELEMENT_CANDLE,x:l_nX,y:l_nY});
  37.    }
  38.    function addElementExit(l_nX, l_nY)
  39.    {
  40.       this.aElementList.push({element:maze.MazeData.ELEMENT_EXIT,x:l_nX,y:l_nY});
  41.    }
  42.    function addElementDutchMan(l_nX, l_nY)
  43.    {
  44.       this.aElementList.push({element:maze.MazeData.ELEMENT_DUTCHMAN,x:l_nX,y:l_nY});
  45.    }
  46.    function addElementVampiRay(l_nX, l_nY, l_nWidth)
  47.    {
  48.       this.aElementList.push({element:maze.MazeData.ELEMENT_VAMPIRAY,x:l_nX,y:l_nY,width:l_nWidth});
  49.    }
  50.    function addElementSkeletuna(l_nX, l_nY)
  51.    {
  52.       this.aElementList.push({element:maze.MazeData.ELEMENT_SKELETUNA,x:l_nX,y:l_nY});
  53.    }
  54.    function addElementToken(l_nX, l_nY)
  55.    {
  56.       this.aElementList.push({element:maze.MazeData.ELEMENT_TOKEN,x:l_nX,y:l_nY});
  57.    }
  58.    function addElementPumpkin(l_nX, l_nY)
  59.    {
  60.       this.aElementList.push({element:maze.MazeData.ELEMENT_PUMPKIN,x:l_nX,y:l_nY});
  61.    }
  62.    function addElementSlug(l_nX, l_nY)
  63.    {
  64.       this.aElementList.push({element:maze.MazeData.ELEMENT_SLUG,x:l_nX,y:l_nY});
  65.    }
  66.    function addElementBurger(l_nX, l_nY)
  67.    {
  68.       this.aElementList.push({element:maze.MazeData.ELEMENT_BURGER,x:l_nX,y:l_nY});
  69.    }
  70.    function addElementWaffle(l_nX, l_nY)
  71.    {
  72.       this.aElementList.push({element:maze.MazeData.ELEMENT_WAFFLE,x:l_nX,y:l_nY});
  73.    }
  74.    function getElementList()
  75.    {
  76.       return this.aElementList;
  77.    }
  78.    function debug()
  79.    {
  80.       var _loc3_ = undefined;
  81.       trace("===================");
  82.       var _loc4_ = 0;
  83.       while(_loc4_ < this.nHeight)
  84.       {
  85.          _loc3_ = "";
  86.          var _loc2_ = 0;
  87.          while(_loc2_ < this.nWidth)
  88.          {
  89.             _loc3_ += this.aGrid[_loc4_][_loc2_];
  90.             _loc2_ = _loc2_ + 1;
  91.          }
  92.          trace(_loc3_);
  93.          _loc4_ = _loc4_ + 1;
  94.       }
  95.    }
  96.    function generateEmptyGrid()
  97.    {
  98.       this.aGrid = [];
  99.       var _loc3_ = 0;
  100.       while(_loc3_ < this.nHeight)
  101.       {
  102.          this.aGrid.push([]);
  103.          var _loc2_ = 0;
  104.          while(_loc2_ < this.nWidth)
  105.          {
  106.             this.aGrid[_loc3_][_loc2_] = maze.MazeData.TILE_EMPTY;
  107.             _loc2_ = _loc2_ + 1;
  108.          }
  109.          _loc3_ = _loc3_ + 1;
  110.       }
  111.    }
  112. }
  113.